#include <iostream>
#include <unordered_map>
#include <map>
#include <string>
using namespace std;

void fun_unordered_map()
{
    unordered_map<string, int> umap;

    umap["apple"] = 2;
    umap["banana"] = 5;
    umap.insert({"orange", 3});
    umap.insert(make_pair("pear", 4));

    if (umap.find("banana") != umap.end())
    {
        cout << "banana value: " << umap["banana"] << endl;
    }

    cout << "[unordered_map]:" << endl;
    for (auto &kv : umap)
    {
        cout << kv.first << " -> " << kv.second << endl;
    }

    umap["apple"] = 10;
    umap.erase("pear");

    cout << "unordered_map size: " << umap.size() << endl;
    cout << "orange exists: " << (umap.count("orange") ? "yes" : "no") << endl;
    cout << endl;
}

void fun_map()
{
    map<string, int> oeap;

    oeap["apple"] = 2;
    oeap["banana"] = 5;
    oeap.insert({"orange", 3});
    oeap.insert(make_pair("pear", 4));

    if (oeap.find("banana") != oeap.end())
    {
        cout << "banana value: " << oeap["banana"] << endl;
    }

    cout << "[map]:" << endl;
    for (auto &kv : oeap)
    {
        cout << kv.first << " -> " << kv.second << endl;
    }

    oeap["apple"] = 10;
    oeap.erase("pear");

    cout << "map size: " << oeap.size() << endl;
    cout << "orange exists: " << (oeap.count("orange") ? "yes" : "no") << endl;
    cout << endl;
}

// int main() {
//     fun_unordered_map();
//     fun_map();
//     return 0;
// }
